package cn.org.wifit.userserver.im.handle;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelHandler.Sharable;

/**
 * 这个handler处理类主要用于解析由IMServer传过来的数据，并交由具体的业务处理类。<br>
 * 由于我们使用potolbuff作为数据的承载体，所以这里主要解析过程就是对potolbuff进行解码<br>
 * 又由于IMUser和IMServer的通信数据并不存在加密情况，所以也就不存在解密的过程
 * @author yinwenjie
 */
@Sharable
public class IMUserToIMServerHandler extends ChannelInboundHandlerAdapter {
	
	public static String SESSIONID;
	
	/* (non-Javadoc)
	 * @see io.netty.channel.ChannelInboundHandlerAdapter#channelActive(io.netty.channel.ChannelHandlerContext)
	 */
	@Override 
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("channelActive(ChannelHandlerContext ctx)");
	}

	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("super.channelInactive(ctx)");
	}

	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		System.out.println("super.channelRead(ctx, msg)");
	}

	@Override
	public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
		System.out.println("super.channelReadComplete(ctx)");
	}

	@Override
	public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
		System.out.println("super.channelRegistered(ctx)");
	}

	@Override
	public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
		System.out.println("super.channelUnregistered(ctx)");
	}

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		System.out.println("super.exceptionCaught(ctx, cause)");
	}
}